
#include <gtest/gtest.h>
#include <iostream>
#include <hfsme/HEvent.h>
#include <hfsme/HState.h>
#include <hfsme/HStateMachine.h>


using namespace HFSME;


struct MyStateMachine:HStateMachine<MyStateMachine>
{

};


//first level state
struct StateL1_A:HState<StateL1_A,MyStateMachine>
{

};
REGISTER_STATE(StateL1_A)

struct StateL1_B:HState<StateL1_B,MyStateMachine>
{

};
REGISTER_STATE(StateL1_B)

struct StateL2_A:HState<StateL2_A,StateL1_A>
{

};
REGISTER_STATE(StateL2_A)

struct StateL3_A:HState<StateL3_A,StateL2_A>
{

};
REGISTER_STATE(StateL3_A)



TEST(SubStateRegistration,BasicRegistration)
{

	//check the registration of the constructors
	ASSERT_EQ(2u,MyStateMachine::getTheTreeStructure().size()) << "Two childs for the state machine";

	ASSERT_EQ(1u,StateL1_A::getTheTreeStructure().size());
	ASSERT_EQ(1u,StateL2_A::getTheTreeStructure().size());
	ASSERT_EQ(0u,StateL1_B::getTheTreeStructure().size()) << "No childs for L1B";

	//check name assignment
	ASSERT_EQ("StateL2_A",StateL2_A::getOrSetName());

	//check id assignment
	ASSERT_TRUE(StateL1_B::getOrSetStateId()>0);
	ASSERT_TRUE(StateL2_A::getOrSetStateId()>0);

}



int main(int argc, char **argv) {
  ::testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}







